﻿using System;
using UnityEngine;

namespace Assets.Scripts
{
    /// <summary>
    /// 乒乓球拍.
    /// </summary>
    public class Racket : MonoBehaviour 
    {
        private void Awake()
        {
            InitWidget();
        }

        private Rigidbody2D _rigid2D;

        /// <summary>
        /// 获取组件的函数.
        /// </summary>
        private void InitWidget()
        {
            _rigid2D = GetComponent<Rigidbody2D>();
        }

        /// <summary>
        /// 球拍的移动.
        /// </summary>
        /// <param name="input">上下键的输入(上1下-1)</param>
        public void Move(float input)
        {
            _rigid2D.velocity = new Vector2(0, input * DataManager.Instance.RacketMoveSpeed);
        }
    }
}
